<%@page contentType="text/html; charset=UTF-8" language="java" %>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-html"  prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@page import="com.kcs.common.utils.commonUtils"%>
<%@page import="com.kcs.common.utils.PropsUtils"%>
<%@page import="com.kcs.common.utils.Constant"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title>Outstanding by Maturity Report</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.easing-1.3.pack.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.pack.js"></script>   
<script type="text/javascript" src="jsp/script/jsDatePick.full.1.3.js"></script>   	 	 	
<script type="text/javascript" src="jsp/script/common.js"></script>  
<link rel="stylesheet" type="text/css" href="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/table.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/fxmarginStyle.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/jsDatePick_ltr.css" />
<script type="text/javascript">

	$(document).ready(function() {
		jQuery("#action").val("init");

		new JsDatePick({
			useMode:2,
			target:"startDate",
			dateFormat:"%d/%m/%Y"});

		new JsDatePick({
			useMode:2,
			target:"endDate",
			dateFormat:"%d/%m/%Y"});
/*
		var first = jQuery("#data tr:first");
		first.remove();

		first = "<tr>​<th rowspan='2'>​Expiry Date​</th>​<th rowspan='2'>​Deal Id​</th>​<th rowspan='2'>​Customer​</th>​<th rowspan='2'>​Deal Date​</th>​<th rowspan='2'>​Base Rate​</th>​<th rowspan='2'>​All in Rate​</th>​<th colspan='2'>​Buy​</th>​<th colspan='2'>​Sell​</th>​</tr>​<tr>​<th>​Ccy​</th>​<th>​Amount​</th>​<th>​Ccy​</th>​<th>​Amount​</th>​</tr>​";

		jQuery("#data thead:first").append(first);*/

		var first = jQuery("#data tr:first");
		first.remove();

		first = "<tr>​<th rowspan='2'>​Expiry Date​​<th rowspan='2'>​Deal Id​​<th rowspan='2'>​Customer​​<th rowspan='2'>​Deal Date​​<th rowspan='2'>​Base Rate​​<th rowspan='2'>​All in Rate​​<th colspan='2'>​Buy​​<th colspan='2'>​Sell​​</tr>​<tr>​<th>​Ccy​​<th>​Amount​​<th>​Ccy​​<th>​Amount​​</tr>​";

		jQuery("#data thead:first").append(first);
		
	});
	
	function exportPDFFunction(){
		jQuery("#action").val("exportToPDF");
		submitform();
	}

	function exportExcelFunction(){
		jQuery("#action").val("exportToExcel");
		submitform();
	}
	
	function search(){
		
		if(validate()){
			loading();
			jQuery("#action").val("search");
			submitform();
		}
		
	}

	function resetFunction(){
		loading();
		jQuery("#action").val("init");
		submitform();
	}

	function validate(){
		var startDate = jQuery("#startDate").val();
		var endDate	  = jQuery("#endDate").val();

		if(startDate == ""){ alert(m_please_fill_data + " Start Date"); return false;}
		if(endDate   == ""){ alert(m_please_fill_data + " End Date"); return false;}

		var startTime 	= (toDate(startDate)).getTime();
		var endTime 	= (toDate(endDate)).getTime();

		if(startTime > endTime) {alert("Start Date not less than End Date"); return false;}

		return true;
	}
	
</script>
</head>
<body><%@ include	file="include/headerMenu.jsp"%>

<center>
<div style="width:95%" align="center">

	<html:form action="/OutstandingReportAction.do">
		<html:hidden property="action" styleId="action"/>
		
		<table width="100%" class="MarginHeader">
			<tr>
				<td align="left">Outstanding by Maturity Report</td>
			</tr>
		</table>
		
		<div class="CriteriaBox">
			
			<table width="100%" class="MarginCriteria">
			
				<tr>
					<td width="25%" align="right">Start Date : </td>
					<td width="25%" align="left" ><html:text property="startDate" styleId="startDate"/> </td>
					<td width="25%" align="right">End Date : </td>
					<td width="25%" align="left" ><html:text property="endDate" styleId="endDate"/> </td>
				</tr>
				<tr>
					<td width="100%" align="center" colspan="4">
						<input type="button" value="Search" class="button" onclick="search();"/>&nbsp;&nbsp;
						<input type="button" value="Reset" class="button" onclick="resetFunction();"/>&nbsp;&nbsp;
						
						<logic:empty name="OutstandingReportActionForm" property="outStandingBOList">
							<input type="button" value="Export PDF" class="button" disabled="disabled"/>&nbsp;&nbsp;
							<input type="button" value="Export Excel" class="button" disabled="disabled"/>
						</logic:empty>
						
						<logic:notEmpty name="OutstandingReportActionForm" property="outStandingBOList">
							<input type="button" value="Export PDF" class="button" onclick="exportPDFFunction();"/>&nbsp;&nbsp;
							<input type="button" value="Export Excel" class="button" onclick="exportExcelFunction();"/>
						</logic:notEmpty>
						
					</td>
				</tr>
			</table>
		</div>
	
		<logic:present name="<%=Constant.SHOW_RESULT%>">
			<div class="MarginTable" >
				<display:table id="data" name="sessionScope.OutstandingReportActionForm.outStandingBOList" requestURI="/OutstandingReportAction.do" pagesize="10"  >
	
					<display:column property="expiryDate"	sortable="false" title="Expiry Date" class="center" format="{0,date,dd/MM/yyyy}"/>
					<display:column property="dealId"   	sortable="false" title="Deal Id" class="center"/>
					<display:column property="customer" 	sortable="false" title="Customer" class="left"/>			
					<display:column property="dealDate" 	sortable="false" title="Deal Date" class="center" format="{0,date,dd/MM/yyyy}"/>
					<display:column property="baseRate"   	sortable="false" title="Base Rate" class="right" format="{0,number,#,##0.00}"/>
					<display:column property="allInRate"	sortable="false" title="All in Rate" class="right" format="{0,number,#,##0.00}"/>			
					<display:column property="ccyBuy" 		sortable="false" title="Ccy" class="center"/>
					<display:column property="buyAmount"	sortable="false" title="Amount" class="right" format="{0,number,#,##0.00}"/>
					<display:column property="ccySell" 		sortable="false" title="Ccy" class="center"/>
					<display:column property="sellAmount" 	sortable="false" title="Amount" class="right" format="{0,number,#,##0.00}"/>	
				</display:table>
			</div>
		</logic:present>

		
		<%@ include	file="include/footer.jsp"%> 
		<%@ include	file="include/message.jsp"%> 
	</html:form>	
		
</div>
</center>


</body>
</html>